<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
<meta name="generator" content="Docutils 0.20.1: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>SeleniumLibrary</title>
<link rel="stylesheet" href="style.css" type="text/css" />
<link rel="stylesheet" href="extra.css" type="text/css" />
</head>
<body class="with-toc">
<main id="seleniumlibrary">
<h1 class="title">SeleniumLibrary</h1>

<nav class="contents" id="contents" role="doc-toc">
<p class="topic-title">Contents</p>
<ul class="simple">
<li><p><a class="reference internal" href="#introduction" id="toc-entry-1">Introduction</a></p></li>
<li><p><a class="reference internal" href="#keyword-documentation" id="toc-entry-2">Keyword Documentation</a></p></li>
<li><p><a class="reference internal" href="#installation" id="toc-entry-3">Installation</a></p></li>
<li><p><a class="reference internal" href="#browser-drivers" id="toc-entry-4">Browser drivers</a></p></li>
<li><p><a class="reference internal" href="#usage" id="toc-entry-5">Usage</a></p></li>
<li><p><a class="reference internal" href="#extending-seleniumlibrary" id="toc-entry-6">Extending SeleniumLibrary</a></p></li>
<li><p><a class="reference internal" href="#community" id="toc-entry-7">Community</a></p></li>
<li><p><a class="reference internal" href="#versions" id="toc-entry-8">Versions</a></p></li>
<li><p><a class="reference internal" href="#history" id="toc-entry-9">History</a></p></li>
</ul>
</nav>
<section id="introduction">
<h2><a class="toc-backref" href="#toc-entry-1" role="doc-backlink">Introduction</a></h2>
<p><a class="reference external" href="https://github.com/robotframework/SeleniumLibrary">SeleniumLibrary</a> is a web testing library for <a class="reference external" href="https://robotframework.org">Robot Framework</a> that
utilizes the <a class="reference external" href="https://www.seleniumhq.org/">Selenium</a> tool internally. The project is hosted on <a class="reference external" href="https://github.com/robotframework/SeleniumLibrary">GitHub</a>
and downloads can be found from <a class="reference external" href="https://pypi.python.org/pypi/robotframework-seleniumlibrary">PyPI</a>.</p>
<p>SeleniumLibrary works with Selenium 3 and 4. It supports Python 3.6 or
newer. In addition to the normal <a class="reference external" href="https://python.org">Python</a> interpreter, it works also
with <a class="reference external" href="https://pypy.org">PyPy</a>.</p>
<p>SeleniumLibrary is based on the <a class="reference external" href="https://github.com/robotframework/OldSeleniumLibrary">old SeleniumLibrary</a> that was forked to
<a class="reference external" href="https://github.com/robotframework/Selenium2Library">Selenium2Library</a> and then later renamed back to SeleniumLibrary.
See the <a class="reference internal" href="#versions">Versions</a> and <a class="reference internal" href="#history">History</a> sections below for more information about
different versions and the overall project history.</p>
<a class="reference external image-reference" href="https://pypi.python.org/pypi/robotframework-seleniumlibrary"><img alt="https://img.shields.io/pypi/v/robotframework-seleniumlibrary.svg?label=version" src="https://img.shields.io/pypi/v/robotframework-seleniumlibrary.svg?label=version" /></a>
<a class="reference external image-reference" href="https://pypi.python.org/pypi/robotframework-seleniumlibrary"><img alt="https://img.shields.io/pypi/dm/robotframework-seleniumlibrary.svg" src="https://img.shields.io/pypi/dm/robotframework-seleniumlibrary.svg" /></a>
<a class="reference external image-reference" href="https://www.apache.org/licenses/LICENSE-2.0"><img alt="https://img.shields.io/pypi/l/robotframework-seleniumlibrary.svg" src="https://img.shields.io/pypi/l/robotframework-seleniumlibrary.svg" /></a>
<a class="reference external image-reference" href="https://github.com/robotframework/SeleniumLibrary/actions/workflows/CI.yml"><img alt="https://github.com/robotframework/SeleniumLibrary/actions/workflows/CI.yml/badge.svg?branch=master" src="https://github.com/robotframework/SeleniumLibrary/actions/workflows/CI.yml/badge.svg?branch=master" /></a>
</section>
<section id="keyword-documentation">
<h2><a class="toc-backref" href="#toc-entry-2" role="doc-backlink">Keyword Documentation</a></h2>
<p>See <a class="reference external" href="https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html">keyword documentation</a> for available keywords and more information
about the library in general.</p>
</section>
<section id="installation">
<h2><a class="toc-backref" href="#toc-entry-3" role="doc-backlink">Installation</a></h2>
<p>The recommended installation method is using <a class="reference external" href="http://pip-installer.org">pip</a>:</p>
<pre class="literal-block">pip install --upgrade robotframework-seleniumlibrary</pre>
<p>Running this command installs also the latest Selenium and Robot Framework
versions, but you still need to install <a class="reference internal" href="#browser-drivers">browser drivers</a> separately.
The <span class="docutils literal"><span class="pre">--upgrade</span></span> option can be omitted when installing the library for the
first time.</p>
<p>Those migrating from <a class="reference external" href="https://github.com/robotframework/Selenium2Library">Selenium2Library</a> can install SeleniumLibrary so that
it is exposed also as Selenium2Library:</p>
<pre class="literal-block">pip install --upgrade robotframework-selenium2library</pre>
<p>The above command installs the normal SeleniumLibrary as well as a new
Selenium2Library version that is just a thin wrapper to SeleniumLibrary.
That allows importing Selenium2Library in tests while migrating to
SeleniumLibrary.</p>
<p>To install the last legacy <a class="reference external" href="https://github.com/robotframework/Selenium2Library">Selenium2Library</a> version, use this command instead:</p>
<pre class="literal-block">pip install robotframework-selenium2library==1.8.0</pre>
<p>With recent versions of <span class="docutils literal">pip</span> it is possible to install directly from the
<a class="reference external" href="https://github.com/robotframework/SeleniumLibrary">GitHub</a> repository. To install latest source from the master branch, use
this command:</p>
<pre class="literal-block">pip install git+https://github.com/robotframework/SeleniumLibrary.git</pre>
<p>Please note that installation will take some time, because <span class="docutils literal">pip</span> will
clone the <a class="reference external" href="https://github.com/robotframework/SeleniumLibrary">SeleniumLibrary</a> project to a temporary directory and then
perform the installation.</p>
<p>See <a class="reference external" href="https://github.com/robotframework/robotframework/blob/master/INSTALL.rst">Robot Framework installation instructions</a> for detailed information
about installing Python and Robot Framework itself. For more details about
using <span class="docutils literal">pip</span> see <a class="reference external" href="http://pip-installer.org">its own documentation</a>.</p>
</section>
<section id="browser-drivers">
<h2><a class="toc-backref" href="#toc-entry-4" role="doc-backlink">Browser drivers</a></h2>
<p>After installing the library, you still need to install browser and
operating system specific browser drivers for all those browsers you
want to use in tests. These are the exact same drivers you need to use with
Selenium also when not using SeleniumLibrary. More information about
drivers can be found from <a class="reference external" href="https://seleniumhq.github.io/selenium/docs/api/py/index.html#drivers">Selenium documentation</a>.</p>
<p>The general approach to install a browser driver is downloading a right
driver, such as <span class="docutils literal">chromedriver</span> for Chrome, and placing it into
a directory that is in <a class="reference external" href="https://en.wikipedia.org/wiki/PATH_(variable)">PATH</a>. Drivers for different browsers
can be found via Selenium documentation or by using your favorite
search engine with a search term like <span class="docutils literal">selenium chrome browser driver</span>.
New browser driver versions are released to support features in
new browsers, fix bug, or otherwise, and you need to keep an eye on them
to know when to update drivers you use.</p>
<p>Alternatively, you can use a tool called <a class="reference external" href="https://github.com/omenia/webdrivermanager">WebdriverManager</a> which can
find the latest version or when required, any version of appropriate
webdrivers for you and then download and link/copy it into right
location. Tool can run on all major operating systems and supports
downloading of Chrome, Firefox, Opera &amp; Edge webdrivers.</p>
<p>Here's an example:</p>
<pre class="code bash literal-block"><code>pip<span class="whitespace"> </span>install<span class="whitespace"> </span>webdrivermanager<span class="whitespace">
</span>webdrivermanager<span class="whitespace"> </span>firefox<span class="whitespace"> </span>chrome<span class="whitespace"> </span>--linkpath<span class="whitespace"> </span>/usr/local/bin</code></pre>
</section>
<section id="usage">
<h2><a class="toc-backref" href="#toc-entry-5" role="doc-backlink">Usage</a></h2>
<p>To use SeleniumLibrary in Robot Framework tests, the library needs to
first be imported using the <span class="docutils literal">Library</span> setting as any other library.
The library accepts some import time arguments, which are documented
in the <a class="reference external" href="https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html">keyword documentation</a> along with all the keywords provided
by the library.</p>
<p>When using Robot Framework, it is generally recommended to write as
easy-to-understand tests as possible. The keywords provided by
SeleniumLibrary is pretty low level, though, and often require
implementation-specific arguments like element locators to be passed
as arguments. It is thus typically a good idea to write tests using
Robot Framework's higher-level keywords that utilize SeleniumLibrary
keywords internally. This is illustrated by the following example
where SeleniumLibrary keywords like <span class="docutils literal">Input Text</span> are primarily
used by higher-level keywords like <span class="docutils literal">Input Username</span>.</p>
<pre class="code robotframework literal-block"><code><span class="generic heading">*** Settings ***</span><span class="punctuation">
</span><span class="keyword namespace">Documentation</span><span class="punctuation">     </span><span class="literal string">Simple example using SeleniumLibrary.</span><span class="punctuation">
</span><span class="keyword namespace">Library</span><span class="punctuation">           </span><span class="name namespace">SeleniumLibrary</span><span class="punctuation">

</span><span class="generic heading">*** Variables ***</span><span class="punctuation">
${</span><span class="name variable">LOGIN URL</span><span class="punctuation">}      </span><span class="literal string">http://localhost:7272</span><span class="punctuation">
${</span><span class="name variable">BROWSER</span><span class="punctuation">}        </span><span class="literal string">Chrome</span><span class="punctuation">

</span><span class="generic heading">*** Test Cases ***</span><span class="punctuation">
</span><span class="generic subheading">Valid Login</span><span class="punctuation">
    </span><span class="name function">Open Browser To Login Page</span><span class="punctuation">
    </span><span class="name function">Input Username</span><span class="punctuation">    </span><span class="literal string">demo</span><span class="punctuation">
    </span><span class="name function">Input Password</span><span class="punctuation">    </span><span class="literal string">mode</span><span class="punctuation">
    </span><span class="name function">Submit Credentials</span><span class="punctuation">
    </span><span class="name function">Welcome Page Should Be Open</span><span class="punctuation">
    [</span><span class="keyword namespace">Teardown</span><span class="punctuation">]    </span><span class="name function">Close Browser</span><span class="punctuation">

</span><span class="generic heading">*** Keywords ***</span><span class="punctuation">
</span><span class="generic subheading">Open Browser To Login Page</span><span class="punctuation">
    </span><span class="name function">Open Browser</span><span class="punctuation">    ${</span><span class="name variable">LOGIN URL</span><span class="punctuation">}    ${</span><span class="name variable">BROWSER</span><span class="punctuation">}
    </span><span class="name function">Title Should Be</span><span class="punctuation">    </span><span class="literal string">Login Page</span><span class="punctuation">

</span><span class="generic subheading">Input Username</span><span class="punctuation">
    [</span><span class="keyword namespace">Arguments</span><span class="punctuation">]    ${</span><span class="name variable">username</span><span class="punctuation">}
    </span><span class="name function">Input Text</span><span class="punctuation">    </span><span class="literal string">username_field</span><span class="punctuation">    ${</span><span class="name variable">username</span><span class="punctuation">}

</span><span class="generic subheading">Input Password</span><span class="punctuation">
    [</span><span class="keyword namespace">Arguments</span><span class="punctuation">]    ${</span><span class="name variable">password</span><span class="punctuation">}
    </span><span class="name function">Input Text</span><span class="punctuation">    </span><span class="literal string">password_field</span><span class="punctuation">    ${</span><span class="name variable">password</span><span class="punctuation">}

</span><span class="generic subheading">Submit Credentials</span><span class="punctuation">
    </span><span class="name function">Click Button</span><span class="punctuation">    </span><span class="literal string">login_button</span><span class="punctuation">

</span><span class="generic subheading">Welcome Page Should Be Open</span><span class="punctuation">
    </span><span class="name function">Title Should Be</span><span class="punctuation">    </span><span class="literal string">Welcome Page</span></code></pre>
<p>The above example is a slightly modified version of an example in a
<a class="reference external" href="https://github.com/robotframework/WebDemo">demo project</a> that illustrates using Robot Framework and SeleniumLibrary.
See the demo for more examples that you can also execute on your own
machine. For more information about Robot Framework test data syntax in
general see the <a class="reference external" href="https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html">Robot Framework User Guide</a>.</p>
</section>
<section id="extending-seleniumlibrary">
<h2><a class="toc-backref" href="#toc-entry-6" role="doc-backlink">Extending SeleniumLibrary</a></h2>
<p>Before creating your own library which extends the <span class="docutils literal">SeleniumLibrary</span>, please consider would
the extension be also useful also for general usage. If it could be useful also for general
usage, please create a new issue describing the enhancement request and even better if the
issue is backed up by a pull request.</p>
<p>If the enhancement is not generally useful, example solution is domain specific, then the
SeleniumLibrary offers public APIs which can be used to build its own plugins and libraries.
Plugin API allows us to add new keywords, modify existing keywords and modify the internal
functionality of the library. Also new libraries can be built on top of the
SeleniumLibrary. Please see <a class="reference external" href="https://github.com/robotframework/SeleniumLibrary/blob/master/docs/extending/extending.rst">extending documentation</a> for more details about the
available methods and for examples how the library can be extended.</p>
</section>
<section id="community">
<h2><a class="toc-backref" href="#toc-entry-7" role="doc-backlink">Community</a></h2>
<p>If the provided documentation is not enough, there are various community channels
available:</p>
<ul class="simple">
<li><p><a class="reference external" href="https://groups.google.com/group/robotframework-users">robotframework-users</a> mailing list</p></li>
<li><p><span class="docutils literal">#seleniumlibrary</span> and <span class="docutils literal"><span class="pre">#seleniumlibrary-dev</span></span> channels in
Robot Framework <a class="reference external" href="https://robotframework-slack-invite.herokuapp.com">Slack community</a></p></li>
<li><p><a class="reference external" href="https://forum.robotframework.org/">Robot Framework forum</a> has channel for SeleniumLibrary.</p></li>
<li><p>SeleniumLibrary <a class="reference external" href="https://github.com/robotframework/SeleniumLibrary/issues">issue tracker</a> for bug reports and concrete enhancement
requests</p></li>
<li><p><a class="reference external" href="https://robotframework.org/#community">Other community channels</a> including paid support</p></li>
</ul>
</section>
<section id="versions">
<h2><a class="toc-backref" href="#toc-entry-8" role="doc-backlink">Versions</a></h2>
<p>SeleniumLibrary has over the years lived under SeleniumLibrary and
Selenium2Library names and different library versions have supported
different Selenium and Python versions. This is summarized in the table
below and the <a class="reference internal" href="#history">History</a> section afterwards explains the project history
a bit more.</p>
<table>
<thead>
<tr><th class="head"><p>Project</p></th>
<th class="head"><p>Selenium Version</p></th>
<th class="head"><p>Python Version</p></th>
<th class="head"><p>Comment</p></th>
</tr>
</thead>
<tbody>
<tr><td><p>SeleniumLibrary 2.9.2 and earlier</p></td>
<td><p>Selenium 1 and 2</p></td>
<td><p>Python 2.5-2.7</p></td>
<td><p>The original SeleniumLibrary using Selenium RC API.</p></td>
</tr>
<tr><td><p>Selenium2Library 1.8.0 and earlier</p></td>
<td><p>Selenium 2 and 3</p></td>
<td><p>Python 2.6-2.7</p></td>
<td><p>Fork of SeleniumLibrary using Selenium WebDriver API.</p></td>
</tr>
<tr><td><p>SeleniumLibrary 3.0 and 3.1</p></td>
<td><p>Selenium 2 and 3</p></td>
<td><p>Python 2.7 and 3.3+</p></td>
<td><p>Selenium2Library renamed and with Python 3 support and new architecture.</p></td>
</tr>
<tr><td><p>SeleniumLibrary 3.2</p></td>
<td><p>Selenium 3</p></td>
<td><p>Python 2.7 and 3.4+</p></td>
<td><p>Drops Selenium 2 support.</p></td>
</tr>
<tr><td><p>SeleniumLibrary 4.0</p></td>
<td><p>Selenium 3</p></td>
<td><p>Python 2.7 and 3.4+</p></td>
<td><p>Plugin API and support for event friging webdriver.</p></td>
</tr>
<tr><td><p>SeleniumLibrary 4.1</p></td>
<td><p>Selenium 3</p></td>
<td><p>Python 2.7 and 3.5+</p></td>
<td><p>Drops Python 3.4 support.</p></td>
</tr>
<tr><td><p>SeleniumLibrary 4.2</p></td>
<td><p>Selenium 3</p></td>
<td><p>Python 2.7 and 3.5+</p></td>
<td><p>Supports only Selenium 3.141.0 or newer.</p></td>
</tr>
<tr><td><p>SeleniumLibrary 4.4</p></td>
<td><p>Selenium 3 and 4</p></td>
<td><p>Python 2.7 and 3.6+</p></td>
<td><p>New PythonLibCore and dropped Python 3.5 support.</p></td>
</tr>
<tr><td><p>SeleniumLibrary 5.0</p></td>
<td><p>Selenium 3 and 4</p></td>
<td><p>Python 3.6+</p></td>
<td><p>Python 2 and Jython support is dropped.</p></td>
</tr>
<tr><td><p>SeleniumLibrary 5.1</p></td>
<td><p>Selenium 3 and 4</p></td>
<td><p>Python 3.6+</p></td>
<td><p>Robot Framework 3.1 support is dropped.</p></td>
</tr>
<tr><td><p>Selenium2Library 3.0</p></td>
<td><p>Depends on SeleniumLibrary</p></td>
<td><p>Depends on SeleniumLibrary</p></td>
<td><p>Thin wrapper for SeleniumLibrary 3.0 to ease transition.</p></td>
</tr>
</tbody>
</table>
</section>
<section id="history">
<h2><a class="toc-backref" href="#toc-entry-9" role="doc-backlink">History</a></h2>
<p>SeleniumLibrary originally used the Selenium Remote Controller (RC) API.
When Selenium 2 was introduced with the new but backwards incompatible
WebDriver API, SeleniumLibrary kept using Selenium RC and separate
Selenium2Library using WebDriver was forked. These projects contained
mostly the same keywords and in most cases Selenium2Library was a drop-in
replacement for SeleniumLibrary.</p>
<p>Over the years development of the old SeleniumLibrary stopped and also
the Selenium RC API it used was deprecated. Selenium2Library was developed
further and replaced the old library as the de facto web testing library
for Robot Framework.</p>
<p>When Selenium 3 was released in 2016, it was otherwise backwards compatible
with Selenium 2, but the deprecated Selenium RC API was removed. This had two
important effects:</p>
<ul class="simple">
<li><p>The old SeleniumLibrary could not anymore be used with new Selenium versions.
This project was pretty much dead.</p></li>
<li><p>Selenium2Library was badly named as it supported Selenium 3 just fine.
This project needed a new name.</p></li>
</ul>
<p>At the same time when Selenium 3 was released, Selenium2Library was going
through larger architecture changes in order to ease future maintenance and
to make adding Python 3 support easier. With all these big internal and
external changes, it made sense to rename Selenium2Library back to
SeleniumLibrary. This decision basically meant following changes:</p>
<ul class="simple">
<li><p>Create separate repository for the <a class="reference external" href="https://github.com/robotframework/OldSeleniumLibrary">old SeleniumLibrary</a> to preserve
its history since Selenium2Library was forked.</p></li>
<li><p>Rename Selenium2Library project and the library itself to <a class="reference external" href="https://github.com/robotframework/SeleniumLibrary">SeleniumLibrary</a>.</p></li>
<li><p>Add new <a class="reference external" href="https://github.com/robotframework/Selenium2Library">Selenium2Library</a> project to ease transitioning from Selenium2Library
to SeleniumLibrary.</p></li>
</ul>
<p>Going forward, all new development will happen in the new SeleniumLibrary
project.</p>
</section>
</main>
</body>
</html>
